<?php
namespace PsiFramework\Classes\Util\Database\Query;

import("Classes.Util.Database.Query.SqlParameter");

use \PsiFramework\Classes\Util\Database\Query\SqlParameter;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The SqlOperation class is a SqlParameter which allows to
 * represent a sql Operation such as "=", "AND", etc.
 *
 * @package classes.util.xpersist.sql
 */
class SqlOperation extends SqlParameter
{

    /**
     * @var the "=" operator
     */
    public static $equal = "=" ;
    /**
     * @var the "LIKE" operator
     */
    public static $like = "LIKE" ;
    /**
     * @var the ">" operator
     */
    public static $greaterThan = ">" ;
    /**
     * @var the ">=" operator
     */
    public static $greaterThanOrEqual = ">=" ;
    /**
     * @var the "<" operator
     */
    public static $lowerThan = "<" ;
    /**
     * @var the "<=" operator
     */
    public static $lowerThanOrEqual = "<=" ;
    /**
     * @var the "<>" operator
     */
    public static $different = "<>" ;

    /**
     * @var the "IS NULL" operator
     */
    public static $isNull = "IS NULL" ;
    /**
     * @var the "IS NOT NULL" operator
     */
    public static $isNotNull = "IS NOT NULL" ;

    /**
     * @var the "AND" operator
     */
    public static $and = "AND" ;
    /**
     * @var the "OR" operator
     */
    public static $or = "OR" ;
    /**
     * @var the IN operator
     */
    public static $in = "IN" ;

    protected /*string*/ $_operator  ;
    protected /*array*/  $_parameters ;

    /**
     * SqlOperation constructor
     *
     * @param $operator        the operator of the operation
     * @param $parameters    the array of SqlParameters
     */
    public function __construct(
        /*string*/ $operator,
        /*array*/ $parameters = array()
    )
    {
        $this->_operator = $operator ;
        $this->_parameters = $parameters ;
    }

    /**
     * This function allows to add a parameter (SqlParameter)
     * to the operation
     *
     * @param $parameter
     */
    public function addParameter(SqlParameter $parameter=null)
    {
        $this->_parameters[] = $parameter ;
    }

    /**
     * Getter for the member variable $operator
     *
     * @return string
     */
    public function getOperator()
    {
        return $this->_operator ;
    }

    /**
     * Getter for the member variable $parameters
     *
     * @return array of SqlParameters
     */
    public function getParameters()
    {
        return $this->_parameters ;
    }

}

